# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import List
from fastapi import APIRouter, Request, Depends
from hypertext import R, response_json
from apps.api.schemas.agent.know import teamed_schema as schema
from apps.api.service.agent.know.teamed_service import KnowTeamedService

router = APIRouter(prefix="/teamed", tags=["知识库团队接口"])


@router.get("/find_user", summary="知识库用户查找", response_model=R[List[schema.KnowTeamedListVo]])
@response_json
async def find_user(params: schema.KnowTeamedSearchIn = Depends()):
    return await KnowTeamedService.find_user(params)


@router.get("/lists", summary="知识库成员列表", response_model=R[List[schema.KnowTeamedListVo]])
@response_json
async def lists(request: Request, params: schema.KnowTeamedSearchIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await KnowTeamedService.lists(user_id, params)


@router.post("/add", summary="知识库成员新增", response_model=R)
@response_json
async def add(request: Request, params: schema.KnowTeamedAddIn):
    user_id: int = int(request.state.user_id)
    return await KnowTeamedService.add(user_id, params)


@router.post("/edit", summary="知识库成员编辑", response_model=R)
@response_json
async def edit(request: Request, params: schema.KnowTeamedEditIn):
    user_id: int = int(request.state.user_id)
    return await KnowTeamedService.edit(user_id, params)


@router.post("/exits", summary="知识库成员删除", response_model=R)
@response_json
async def exits(request: Request, params: schema.KnowTeamedExitsIn):
    user_id: int = int(request.state.user_id)
    return await KnowTeamedService.exits(user_id, params.kb)


@router.post("/delete", summary="知识库成员删除", response_model=R)
@response_json
async def delete(request: Request, params: schema.KnowTeamedDeleteIn):
    user_id: int = int(request.state.user_id)
    return await KnowTeamedService.delete(user_id, params.id)
